import Vue from 'vue'
import co from 'co'
import * as Util from '../../components/Util'

// let overChargeGen = function * (model, row) {
  // let result = yield co(overCharge(model, row))
// }
let changeMeterGen = function * (model, row) {
  if (row.f_meter_type === '机表' || row.f_meter_type === '物联网表' || row.f_meter_type === '远传表') {
    let handplan = {
      f_last_tablebase: row.f_meter_base,
      f_tablebase: model.f_tablebase - 0,
      f_whether_pay: '否',
      f_oughtamount: (model.f_tablebase - 0) - (row.f_meter_base - 0),
      f_meter_state: '已抄表',
      f_operator: Util.f.name,
      f_inputtor: Util.f.name,
      f_hand_date: Util.toStandardTimeString(),
      f_input_date: Util.toStandardTimeString(),
      f_end_date: Util.addDate(Util.toStandardTimeString(), model.lazy),
      f_price_id: row.f_price_id,
      userfile: row.f_user_id,
      record_userinfo: row.f_userinfo_id,
      f_userinfo_id: row.f_userinfo_id,
      f_user_name: row.f_user_name,
      f_user_type: row.f_user_type,
      f_gasproperties: row.f_gasproperties,
      f_address: row.f_address,
      f_meter_brand: row.f_meter_brand,
      f_meter_style: row.f_meter_style,
      f_meternumber: row.f_meternumber
    }
    return Vue.resetpost('rs/logic/machineOwe', {data: {row: row, handplan: handplan}}, {resolveMsg: null, rejectMsg: null})
  } else if (row.f_meter_type === '气量卡表') {
    let overuse = {
      f_overuseamount: (model.f_tablebase - 0) - (row.f_meter_base - 0),
      f_overusefee: '',
      f_whether_pay: '否',
      f_overuse_state: '有效',
      f_user_id: row.f_user_id + '',
      record_userinfo: row.f_userinfo_id + '',
      f_userinfo_id: row.f_userinfo_id + '',
      f_user_name: row.f_user_name,
      f_address: row.f_address,
      f_operat_type: '卡表超用',
      f_describe: `${Util.f.name}对用户${row.f_user_name}的${row.f_meter_brand}表进行超用收费操作`,
      f_state: '有效',
      f_operator: Util.f.name,
      f_filiale: Util.f.f_fengongsi,
      f_outlets: Util.f.f_parentname
    }

    // 获得应交金额
    // let result = yield co(Vue.CommonService.gasCalculate(row, data.f_overuseamount))
    // data.f_overusefee = result.data.chargenum

    return Vue.resetpost('rs/logic/cardMeterOwe', {data: {row: row, overuse: overuse}}, {resolveMsg: null, rejectMsg: '超用收费存库失败'})
    // return Vue.resetpost('rs/entity/t_overuse', data, {resolveMsg: null, rejectMsg: null})
  } else if (row.f_meter_type === '金额卡表') {
    let overuse = {
      f_overusefee: (0 - (model.f_tablebase - 0)),
      f_whether_pay: '否',
      f_overuse_state: '有效',
      f_user_id: row.f_user_id + '',
      record_userinfo: row.f_userinfo_id + '',
      f_userinfo_id: row.f_userinfo_id + '',
      f_user_name: row.f_user_name,
      f_address: row.f_address,
      f_operat_type: '卡表超用',
      f_describe: `${Util.f.name}对用户${row.f_user_name}的${row.f_meter_brand}表进行超用收费操作`,
      f_state: '有效',
      f_operator: Util.f.name,
      f_filiale: Util.f.f_fengongsi,
      f_outlets: Util.f.f_parentname
    }
    // 获得应交气量
    // let result = yield co(Vue.CommonService.feeCalculate(row, (0 - (model.f_tablebase - 0))))
    // data.f_overuseamount = result.data.gas
    return Vue.resetpost('rs/logic/feeMeterOwe', {data: {row: row, overuse: overuse}}, {resolveMsg: null, rejectMsg: '超用收费存库失败'})
  }
}

// 只换表
let onlyChangeNewMeterGen = function * (model, data) {
  let result
  try {
    let cardState = yield co(Vue.resetpost('http://127.0.0.1:8003/hasCard', {data: {}}, {resolveMsg: null, rejectMsg: null}))
    if (JSON.parse(cardState.data).state === 1) {
      // 存库
      result = yield Vue.resetpost('rs/logic/changeMeter', {data: data}, {resolveMsg: null, rejectMsg: '换表失败'})

      // 获取气价和售气情况参数
      let cardParams = yield co(getParamGen(result.data.cardnumber))

      // 写卡
      let params = {
        factory: model.metermessage.gasbrand[0].f_alias,
        kmm: '000000',                                       // 卡密码，写卡后返回新密码, 不论补卡还是先开户都没有密码
        kzt: '0',                                            // 卡状态，0开户卡，1用户卡（0新开户，1补卡）
        kh: result.data.cardnumber,                          // 卡号
        yhh: data.f_meterid,                                            // 用户号，档案中自己输
        ql: 0,                                               // 预购气量
        csql: 0,                                           // 上次购气量，新开户为0
        ccsql: 0,                                          // 上上次购气量，新开户为0
        cs: 1,                                             // 求购气次数，先开户为1
        ljgql: 0,                                            // 当前累计购气量
        bkcs: 0,                                           // 新开户卡，为0
        ljyql: 0,                                          // 累积用气量，有些表要累加原来用气量,新开户卡，为0
        bjql: model.metermessage.gasbrand[0].f_police_gas,                              // 报警气量,t_gasbrand表中
        czsx: model.metermessage.gasbrand[0].f_topup_ceil,                              // 充值上线，t_gasbrand表中
        tzed: model.metermessage.gasbrand[0].f_overdr_lines,                            // 透支额度，t_gasbrand表中
        cssqrq: '',                                          // 上次售气日期，格式为YYYYMMDD
        // sxrq: model.f_startdate,                             // 生效日期，价格管理中取
        meterid: model.metermessage.f_meternumber                          // 表号
        // money: model.f_preamount,                         // 购气金额
      }
      params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
      let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {resolveMsg: null, rejectMsg: '补气卡服务错误'}))
      // 卡服务写卡异常，业务逻辑回滚
      if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
        let data = {
          id: result.data.id
        }
        yield Vue.resetpost('rs/logic/changeMeterRollback', {data: data}, {resolveMsg: '换表成功，写卡失败', rejectMsg: '换表成功，写卡失败'})
      } else {
        let change = {
          userfiles: {
            f_user_id: data.f_user_id,
            version: data.version,
            f_card_id: result.data.cardnumber,
            f_times: 0,
            f_card_password: cardRes.data.Kmm
          },
          record: {
            id: result.data.id,
            f_state: '有效'
          }
        }
        yield Vue.resetpost('rs/logic/updatemark', {data: change}, {resolveMsg: '换表成功', rejectMsg: '换表成功，更新状态有效失败'})
      }
    } else {
      Vue.showAlert('请检查卡是否插好！！', 'danger', 3000)
    }
  } catch (error) {
    let msg = ''
    if (error.status === 612) {
      msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
    } else {
      msg = '换表失败!!'
      let data = {
        id: result.data.id
      }
      yield Vue.resetpost('rs/logic/changeMeterRollback', {data: data}, {resolveMsg: '换表成功，写卡失败', rejectMsg: '换表成功，写卡失败'})
    }
    Vue.showAlert(msg, 'danger', 0)
  }
}

let changeNewMeterGen = function * (type, data) {
  if (type === '物联网表') {
    data.changemeter.userfiles.f_table_state = '未发送'
  }
  return co(Vue.resetpost('rs/logic/changeMeter', {data: data}))
}

// 换表并补气
let changeAndPlusGen = function * (self, model, row) {
  let result
  try {
    let cardState = yield co(Vue.resetpost('http://127.0.0.1:8003/hasCard', {data: {}}, {resolveMsg: null, rejectMsg: null}))
    if (JSON.parse(cardState.data).state === 1) {
      let data = self.getData(model, row)
      data.changemeter.userfiles.f_times = 1
      console.log('换成的表是：', model.metermessage.gasbrand[0].f_meter_type)
      data.changemeter.userfiles.f_meter_base = model.metermessage.gasbrand[0].f_meter_type === '金额卡表' ? (model.f_pregas - 0) : (model.metermessage.f_meter_base - 0) + (model.f_pregas - 0)
      data.changemeter.userfiles.f_total_fee = (model.f_preamount - 0)
      data.changemeter.f_state = '未知'
      // 返回卡号
      result = yield Vue.resetpost('rs/logic/changeMeter', {data: data}, {resolveMsg: null, rejectMsg: '换表并补气卡服务错误'})

      // 获取气价和售气情况参数
      let cardParams = yield co(getParamGen(result.data.cardnumber, model.metermessage.gasbrand[0].f_alias))
      console.log('获取写卡参数，，，，123', cardParams)
      // 写卡
      let params = {
        factory: model.metermessage.gasbrand[0].f_alias,
        kmm: '000000',                                       // 卡密码，写卡后返回新密码, 不论补卡还是先开户都没有密码
        kzt: '0',                                            // 卡状态，0开户卡，1用户卡（0新开户，1补卡）
        kh: result.data.cardnumber,                          // 卡号
        yhh: data.f_meterid,                                 // 用户号，档案中自己输
        ql: parseInt(model.f_pregas).toString(),                                  // 预购气量
        cs: '1',                                             // 求购气次数，先开户为1
        ljgql: parseInt(model.f_pregas).toString(),                               // 当前累计购气量
        bkcs: '0',                                           // 新开户卡，为0
        ljyql: '0',                                          // 累积用气量，有些表要累加原来用气量,新开户卡，为0
        bjql: model.metermessage.gasbrand[0].f_police_gas,   // 报警气量,t_gasbrand表中
        czsx: model.metermessage.gasbrand[0].f_topup_ceil,   // 充值上线，t_gasbrand表中
        tzed: model.metermessage.gasbrand[0].f_overdr_lines, // 透支额度，t_gasbrand表中
        cssqrq: '',                                          // 上次售气日期，格式为YYYYMMDD
        // sxrq: model.f_startdate,                             // 生效日期，价格管理中取
        meterid: row.f_meternumber,                          // 表号
        money: model.f_preamount,
        totalmoney: model.f_preamount
      }
      params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
      console.log('换表补气写卡参数，，，，', params)
      let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {resolveMsg: null, rejectMsg: '换表并补气卡服务错误'}))
      if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
        // 换表业务进行手动回滚
        yield Vue.resetpost('rs/logic/changeMeterRollback', {data: {id: result.data.id, fillgas_id: result.data.fillgas_id}}, {resolveMsg: '换表并补气失败', rejectMsg: '换表并补气失败'})
      } else {
        // 如果成功修改标识(更新状态为有效)，将返回的卡密码写回数据库
        let plusgas = {
          userfiles: {
            f_user_id: data.f_user_id,
            f_times: 1,
            version: data.version,
            f_card_id: result.data.cardnumber,
            f_card_password: cardRes.data.Kmm
          },
          record: {
            id: result.data.fillgas_id,
            f_state: '有效'
          }
        }
        let changemeter = {
          userfiles: {},
          record: {
            id: result.data.id,
            f_state: '有效'
          }
        }
        yield Vue.resetpost('rs/logic/updatemark', {data: changemeter}, {resolveMsg: null, rejectMsg: null})
        yield Vue.resetpost('rs/logic/updatemark', {data: plusgas}, {resolveMsg: '换表并补气成功', rejectMsg: '换表并补气修改状态失败'})
      }
    } else {
      Vue.showAlert('请检查卡是否插好！！', 'danger', 3000)
    }
  } catch (error) {
    let msg = ''
    if (error.status === 612) {
      msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
    } else {
      msg = '换表补气失败!!'
      yield Vue.resetpost('rs/logic/changeMeterRollback', {data: {id: result.data.id, fillgas_id: result.data.fillgas_id}}, {resolveMsg: '换表并补气失败', rejectMsg: '换表并补气失败'})
    }
    Vue.showAlert(msg, 'danger', 0)
  }
}

// 单独换表补气界面
let AddGasWriteCardGen = function * (model, row) {
  let result
  try {
    let cardState = yield co(Vue.resetpost('http://127.0.0.1:8003/hasCard', {data: {}}, {resolveMsg: null, rejectMsg: null}))
    if (JSON.parse(cardState.data).state === 1) {
      // 存库
      result = yield co(AddGasGen(model, row))
      // 获取气价和售气情况参数
      let cardParams = yield co(getParamGen(row.f_card_id, row.f_alias))

      // 写卡
      let params = {
        factory: row.f_alias,                                // 气表厂家
        kh: row.f_card_id,                                   // 卡号
        kmm: row.f_card_password,                            // 卡密码，写卡后返回新密码, 不论补卡还是先开户都没有密码
        bjql: row.f_police_gas,                              // 报警气量,t_gasbrand表中
        czsx: row.f_topup_ceil,                              // 充值上线，t_gasbrand表中
        tzed: row.f_overdr_lines,                            // 透支额度，t_gasbrand表中
        bkcs: model.f_replace_time,                          // 补卡次数，从补卡表里通过表编号获得
        ql: model.f_fillgas,                                  // 预购气量
        cs: 1                                               // 求购气次数，先开户为1
      }
      params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
      let cardRes
      if (row.f_states === '换表') {
        cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {resolveMsg: null, rejectMsg: '补气卡服务错误'}))
      } else {
        params.cs = row.cardInfo.Times + 1
        cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '补气卡服务错误'}))
      }
      // 卡服务写卡异常，业务逻辑回滚
      if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
        let data = {
          userfile: {
            f_user_id: row.f_user_id,
            f_remanent_gas: model.f_lastremain_fillgas,
            version: 0
          },
          fillgas_id: result.data + ''
        }
        yield Vue.resetpost('rs/logic/addGasRoolBack', {data: {userfile: data.userfile, fillgas_id: data.fillgas_id}}, {resolveMsg: '补气失败', rejectMsg: '补气失败'})
      } else {
        let update = {
          userfiles: {
            f_user_id: row.f_user_id,
            f_meter_base: (row.f_meter_base - 0) + (model.f_fillgas - 0),
            f_remanent_gas: model.theremain_fillgas,
            f_times: 1,
            version: 0
          },
          record: {
            id: result.data,
            f_state: '有效'
          }
        }
        yield Vue.resetpost('rs/logic/updatemark', {data: update}, {resolveMsg: '补气成功', rejectMsg: '补气修改状态失败'})
      }
    } else {
      Vue.showAlert('请检查卡是否插好！！', 'danger', 3000)
    }
  } catch (error) {
    console.log('换表报错。。。', error)
    let msg = ''
    if (error.status === 612) {
      msg = '请检查读卡器时候连接,或者卡服务是否启动！！'
    } else {
      msg = '换表补气失败！！'
      let data = {
        userfile: {
          f_user_id: row.f_user_id,
          f_remanent_gas: model.f_lastremain_fillgas,
          version: 0
        },
        fillgas_id: result.data + ''
      }
      Vue.resetpost('rs/logic/addGasRoolBack', {data: {userfile: data.userfile, fillgas_id: data.fillgas_id}}, {resolveMsg: '补气失败', rejectMsg: '补气失败'})
    }
    Vue.showAlert(msg, 'danger', 0)
  }
}

let AddGasGen = function * (model, row) {
  let data = {
    fillgas: {
      f_meter_brand: row.f_meter_brand,
      f_fillgas: model.f_fillgas,
      f_card_id: row.f_card_id,
      f_lastremain_fillgas: model.f_lastremain_fillgas,
      f_theremain_fillgas: model.f_theremain_fillgas,
      f_reason: model.f_reason,
      f_fillgas_type: model.f_fillgas_type[0],
      f_fillgas_state: '有效',
      f_userinfo_id: row.f_userinfo_id,
      f_user_id: row.f_user_id,
      record_userinfo: row.f_userinfo_id,
      f_user_name: row.f_user_name,
      f_operat_type: '补气',
      f_describe: `${Util.f.name}对用户${row.f_user_name}进行补气操作`,
      f_state: '未知',
      f_operator: Util.f.name,
      userfile: {
        f_user_id: row.f_user_id,
        f_remanent_gas: model.f_theremain_fillgas,
        version: row.version
      }
    }
  }
  data.fillgas.userfile.f_times = row.states === '换表' ? 1 : row.cardInfo.Times + 1
  return co(Vue.resetpost('rs/logic/changePlus', {data: data}, {resolveMsg: null, rejectMsg: '换表气补气存库失败'}))
}
let getParamGen = function * (id, alias) {
  let data = {
    f_card_id: id + '',
    f_alias: alias
  }
  return co(Vue.resetpost('rs/logic/stairCard', {data: data}, {resolveMsg: null, rejectMsg: '获取写卡参数失败'}))
}
let ChangeMeterService = {
  install (Vue, options) {
    // 给vue增添对话框显示方法
    Vue.ChangeMeterService = Vue.prototype.$ChangeMeterService = ChangeMeterService
  },
  // 换表
  changeMeter (model, row) {
    let change = changeMeterGen(model, row)
    return co(change)
  },
  getData (model, row) {
    return {
      changemeter: {
        userfiles: {
          f_user_id: row.f_user_id + '',
          // f_userinfo_id: row.f_userinfo_id,
          f_position: model.metermessage.f_position[0],
          // f_aroundmeter: '左表',
          f_meter_base: model.metermessage.f_meter_base === '' ? 0 : model.metermessage.f_meter_base,
          f_meternumber: model.metermessage.f_meternumber,
          f_metertitles: model.metermessage.f_metertitles,
          f_meter_classify: model.metermessage.gasbrand[0].f_meter_type,
          f_gasbrand_id: model.metermessage.gasbrand[0].id,
          f_gasmodel_id: model.metermessage.gasmodel[0].id,
          f_remanent_gas: 0,
          // f_inputtor: model.metermessage.f_inputtor[0],
          f_price_id: row.f_price_id,
          f_card_id: '',
          f_times: 1,
          f_initial_base: model.metermessage.f_meter_base === '' ? 0 : model.metermessage.f_meter_base,
          f_table_state: '正常',
          f_user_type: row.f_user_type,
          f_gasproperties: row.f_gasproperties,
          version: row.version
        },
        f_user_id: row.f_user_id + '',
        f_userinfo_id: row.f_userinfo_id + '',
        f_user_name: row.f_user_name,
        f_changemeter_type: model.f_changemeter_type[0],
        f_changemeter_fee: model.f_changemeter_fee,
        f_meternumber: row.f_meternumber,
        f_newmeternumber: model.metermessage.f_meternumber,
        f_metertitles: row.f_metertitles,
        f_newmetertitles: model.metermessage.f_metertitles,
        f_card_id: row.f_card_id,
        f_newcard_id: '',
        f_card_password: row.f_card_password,
        f_newcard_password: '',
        f_meter_base: row.f_meter_base,
        f_using_base: row.f_tablebase,
        f_surplus_fee: model.f_preamount,
        f_newmeter_base: model.metermessage.f_meter_base === '' ? 0 : model.metermessage.f_meter_base,
        f_initial_base: row.f_initial_base,
        f_newinitial_base: model.metermessage.f_meter_base === '' ? 0 : model.metermessage.f_meter_base,
        f_times: row.times,
        f_newtimes: 0,
        f_meter_classify: row.f_meter_classify,
        f_newmeter_classify: model.metermessage.gasbrand[0].f_meter_type,
        f_meterid: row.f_meterid,
        f_newmeterid: '',
        f_remanent_gas: row.f_remanent_gas,
        f_newremanent_gas: model.f_newremanent_gas,

        // 物联网表
        f_table_state: row.f_table_state,
        f_newtable_state: '待发送',
        f_valve_state: row.f_valve_state,
        f_newvalve_state: '待发送',

        f_gasbrand_id: row.f_gasbrand_id,
        f_newgasbrand_id: model.metermessage.gasbrand[0].id,
        f_gasmodel_id: row.f_gasmodel_id,
        f_newgasmodel_id: model.metermessage.gasmodel[0].id,
        f_changemeter_state: '有效',
        record_userinfo: row.f_userinfo_id,
        f_reason: model.f_reason[0],
        f_othereason: model.f_othereason,
        f_operat_type: '换表',
        f_describe: `${Util.f.name}对用户${row.f_user_name}进行换新表操作`,
        f_state: '有效',
        f_operator: Util.f.name,
        f_filiale: Util.f.f_fengongsi,
        f_outlets: Util.f.f_parentname,
        f_change_operator: model.f_change_operator[0],
        f_changemeter_date: model.f_changemeter_date
      },
      // olduserfiles: {
      //   f_user_id: row.f_user_id,
      //   f_table_state: '拆除',
      //   version: 0
      // },
      // 是否换成卡表
      changeToCard: model.isCardMeter,
      // 是否补气
      isfillgas: model.isfillgas,
      // 气表品牌，用于获取卡号
      gasbrand: model.metermessage.gasbrand[0].f_meter_brand,

      // 更新账户结余
      f_oldbalance: row.f_balance,
      userinfo_version: row.userinfo_version,
      f_newbalance: model.f_newbalance,
      fillgas: {
        f_card_id: row.f_card_id,
        f_fillgas: model.f_pregas,
        f_fillgas_fee: model.f_preamount,
        f_lastremain_fillgas: model.f_newremanent_gas,
        f_theremain_fillgas: (model.f_newremanent_gas - 0) - (model.f_pregas - 0),
        f_reason: '换新表时旧表有剩余',
        f_fillgas_type: '换表补气',
        f_fillgas_state: '有效',
        f_user_id: row.f_user_id + '',
        record_userinfo: row.f_userinfo_id,
        f_userinfo_id: row.f_userinfo_id + '',
        f_user_name: row.f_user_name,
        f_operat_type: '补气',
        f_describe: `${Util.f.name}对用户${row.f_user_name}进行补气操作`,
        f_state: '未知',
        f_operator: Util.f.name,
        f_filiale: Util.f.f_fengongsi,
        f_outlets: Util.f.f_parentname
      }
    }
  },
  changeAndPlus (model, row) {
    return co(changeAndPlusGen(this, model, row))
  },
  changeNewMeter (model, row) {
    // 换成机表不做写卡操作
    if (model.metermessage.gasbrand[0].f_meter_type === '物联网表' ||
        model.metermessage.gasbrand[0].f_meter_type === '远传表' ||
        model.metermessage.gasbrand[0].f_meter_type === '机表') {
      return co(changeNewMeterGen(model.metermessage.gasbrand[0].f_meter_type, this.getData(model, row)))
    } else {
      return co(onlyChangeNewMeterGen(model, this.getData(model, row)))
    }
  },
  overCharge (model, row) {
    let data = {
      record_userinfo: row.f_userinfo_id,
      f_balance: model.f_balance,
      f_curbalance: model.f_curbalance,
      f_meter_type: row.f_meter_classify,
      f_preamount: model.f_preamount,
      f_pregas: model.f_pregas,
      f_payment: model.f_payment[0],
      f_price_id: row.f_price_id,
      f_user_id: row.f_user_id,
      f_user_name: row.f_user_name,
      f_user_type: row.f_user_type,
      f_gasproperties: row.f_gasproperties,
      f_address: row.f_address,
      f_meter_brand: row.f_meter_brand,
      f_meter_style: row.f_meter_style,
      f_meternumber: row.f_meternumber,
      f_collection: model.f_collection,
      f_delaypay: 0,
      f_operator: Util.f.name,
      f_filiale: Util.f.f_fengongsi,
      f_outlets: Util.f.f_parentname,
      f_charge_type: '超用收费',
      f_charge_state: '有效',
      f_operat_type: '超用收费',
      f_describe: `换表超用,${Util.f.name}对用户${row.f_user_name}进行卡表超用操作`,
      f_state: '有效',
      over: {
        id: model.over_id,
        f_whether_pay: '是'
      }
    }
    if (row.f_meter_classify === '金额卡表') {
      data.f_tablebase = 0
      data.f_last_tablebase = row.f_meter_base
      data.userinfo = {
        f_userinfo_id: row.f_userinfo_id,
        version: row.userinfo_version,
        f_balance: (row.f_balance - 0) - (model.f_preamount - 0) + (model.f_collection - 0),
        userfiles: {
          f_user_id: model.f_user_id,
          f_meter_base: parseFloat(model.f_pregas) + parseFloat(row.f_meter_base),
          version: row.version
        }
      }
    } else if (row.f_meter_classify === '气量卡表') {
      data.f_tablebase = model.f_pregas
      data.f_last_tablebase = row.f_meter_base
      data.userinfo = {
        f_userinfo_id: row.f_userinfo_id,
        version: row.userinfo_version,
        f_balance: (row.f_balance - 0) - (model.f_preamount - 0) + (model.f_collection - 0),
        userfiles: {
          f_user_id: model.f_user_id,
          f_meter_base: parseFloat(model.f_pregas) + parseFloat(row.f_meter_base),
          version: row.version
        }
      }
    }
    return Vue.resetpost('rs/logic/overCharge', {data: data}, {resolveMsg: '超用收费成功', rejectMsg: '超用收费失败'})
  },
  AddGasWriteCard (model, row) {
    return co(AddGasWriteCardGen(model, row))
  }
}

export default ChangeMeterService
